// xShare.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "resource.h"
#include "xShare.h"
#include "Network/Network.h"
#include "ShareData/ShareData.h"
#include "Window/Wnd.h"
#include "MsgFilter/ClipboardFilter.h"
#include "Tray/Tray.h"
#include "event/tray_event_listener.h"

int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    Network::Instance()->Init(&g_oData);

    CxWnd oWnd;
    CClipboardFilter oFilter;
    oWnd.RegisterFilter(0, &oFilter);

    oWnd.Create(0, 0, 100, 100, HWND_MESSAGE);
    oWnd.ShowWindow(SW_SHOW);

    ::SetClipboardViewer(oWnd.GetHWND());

    CxTray oTray(IDI_TRAY);

    CxTrayEventListener oTrayListener;

    oTray.AddEventListener(&oTrayListener);

    //HWND hwnd = ::CreateWindow(L"", L"", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, hInstance, 0);

    xBase::ThreadMgr::Instance()->AttachThread(::GetCurrentThreadId(), xBase::LOOP_TYPE_UI, "attached ui thread");

    BOOL bRet = xBase::ThreadMgr::Instance()->RunMessageLoop();

    //return (int) bRet;

    return 0;
}